package com.example.uiclassassignments.tools;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.example.uiclassassignments.R;

public class ItemGriviewMainAdapter extends BaseAdapter {

    private ArrayList<ItemGriViewDate> itemGriViewDates;

    private Context context;
    private LayoutInflater layoutInflater;

    public ArrayList<ItemGriViewDate> itemGriViewDates() {
        return itemGriViewDates;
    }

    public void setmArrayGridViewItemData(ArrayList<ItemGriViewDate> itemGriViewDates) {
        this.itemGriViewDates = itemGriViewDates;
    }

    public ItemGriviewMainAdapter(Context context, ArrayList<ItemGriViewDate> itemGriViewDates) {
        this.layoutInflater = LayoutInflater.from(context);
        this.itemGriViewDates=itemGriViewDates;
    }
    @Override
    public int getCount() {
        return itemGriViewDates.size();
    }

    @Override
    public ItemGriViewDate getItem(int position) {
        return itemGriViewDates.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.item_griview_main, null);
            convertView.setTag(new ViewHolder(convertView));
        }
        initializeViews((ItemGriViewDate)getItem(position), (ViewHolder) convertView.getTag());
        return convertView;
    }

    private void initializeViews(ItemGriViewDate itemGriViewDate, ViewHolder holder) {
        //TODO implement
        holder.btnItemMain.setText(itemGriViewDate.text);

    }

    protected class ViewHolder {
        private Button btnItemMain;

        public ViewHolder(View view) {
            btnItemMain = (Button) view.findViewById(R.id.btn_item_main);
        }
    }
}
